// 计算平均成绩
let enrollment = [
  { enrolled: 2, grade: 100 },
  { enrolled: 2, grade: 80 },
  { enrolled: 1, grade: 90 }
]

// 命令时
var totalGrades = 0;
var totalFound = 0;
for(let i = 0; i < enrollment.length; i++) {
  let student = enrollment[i];
  if (student !== null) {
    if (student.enrolled > 1) {
      totalGrades += student.grade;
      totalFound++;
    }
  }
}
var average = totalGrades / totalFound;